<?php

class LoginController extends AbstractController {

	public function indexAction() {
		$this->template('index/login.phtml');
	}

	public function submitAction() {
		$member = $this->getRequest()->getPost('member');
		$find = DbMembersModel::getByLoginName($member['loginName']);
		if (!$find) {
			$this->showMsg('账号或密码错误，请重新输出');
		}
		if ($this->genPassword($member['password']) != $find[0]['password']) {
			$this->showMsg('账号或密码错误，请重新输出');
		}
		$session = Session::getInstance();
		$session->set('Member', $find[0]['memberId']);
		$session->set('LoginTime', $this->now());
		$session->send();
		$this->showMsg('登录成功', $this->getURI(''));
	}
}